<template>
  <div class="app">
    <h1>{{ msg }}</h1>
    <School :getSchoolName="getSchoolName"></School>
    <Student @getStudentName="getStudentName"></Student>
    <Student ref="student"></Student>

  </div>
</template>

<script>
import Student from "./components/Student";
import School from "./components/School";

export default {
  name: "App",
  components: {Student, School},
  data() {
    return {
      msg: '你好啊！'
    }
  },
  methods: {
    getSchoolName(name) {
      console.log(name)
    },
    getStudentName(name) {
      console.log('App接收到了学生姓名：', name)
    },
  },
  mounted() {
    this.$refs.student.$on('getStudentName',this.getStudentName)
  }
}
</script>

<style scoped>
.app {
  background-color: #dddddd;
  padding: 5px;
}
</style>